package com.teaphy.coroutinecrawler.flow.operators.transform

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*

fun main() = runBlocking {
    val chars = listOf("A", "B", "C", "D")

    flowOf(1, 2, 3)
        .onEach { println("onEach: $it") }
        .flatMapLatest {
            println("flatMapLatest --> data: $it")
            flow {
                for (ele in 0..it) {
                    emit("$it - ${chars[ele]}")
                    delay(100)
                }
            }
        }.collect {
            println(it)
        }
    println("Done")
}